<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>xilloader: xloader_secure.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="HTML_custom.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="xlogo_bg.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">xilloader
   </div>
   <div id="projectbrief">Vitis Drivers API Documentation</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Overview</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="globals.html"><span>APIs</span></a></li>
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;"
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('xloader__secure_8c.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">xloader_secure.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Overview</h2>
<div class="textblock"><p>This file contains all common security operations including sha related code. </p>
<pre>
MODIFICATION HISTORY:</pre><pre>Ver   Who  Date     Changes
</p>
<hr/>
<p>
1.00  vns  04/23/19 First release
1.01  vns  05/13/19 Added grey key decryption support
      vns  06/14/19 Removed SHA padding related code
      vns  07/09/19 Added PPK and SPK integrity checks
                    Updated chunk size for secure partition
                    Added encryption + authentication support
      vns  07/23/19 Added functions to load secure headers
      vns  08/23/19 Added buffer cleaning on failure
                    Added different key sources support
                    Added header decryption support
                    Set hardware into reset upon failure
      sb   08/24/19  Fixed coverity warnings
      har  08/26/19 Fixed MISRA C violations
      vns  08/28/19 Fixed bug in loading bigger secure CDOs
1.02  vns  02/23/20 Added DPA CM enable/disable functionality
      vns  02/26/20 Added encryption revoke checks
                    Added DEC_ONLY checks
                    Updated PDI fields
                    Added DPA CM enable/disable for MetaHeader
      har  02/24/20 Added code to return error codes
      rpo  02/25/20 Added SHA, RSA, ECDSA, AES KAT support
      vns  03/01/20 Added PUF KEK decrypt support
      ana  04/02/20 Added crypto engine KAT test function calls
                    Removed release reset function calls from this file
                    and added in respective library files
      bsv  04/07/20 Change DMA name to PMCDMA
      vns  04/13/20 Moved Aes instance to Secure structure
1.03  ana  06/04/20 Minor Enhancement and updated Sha3 hash buffer
                    with XSecure_Sha3Hash Structure
      tar  07/23/20 Fixed MISRA-C required violations
      skd  07/29/20 Updated device copy macros
      kpt  07/30/20 Added Meta header IV range checks and added IV
                    support for ENC only case
      kpt  08/01/20 Corrected check to validate the last row of ppk hash
      bsv  08/06/20 Added delay load support for secure cases
      kpt  08/10/20 Corrected endianness for meta header IV range checking
      har  08/11/20 Added support for authenticated JTAG
      td   08/19/20 Fixed MISRA C violations Rule 10.3
      kal  08/23/20 Added parallel DMA support for Qspi and Ospi for secure
      har  08/24/20 Added support for ECDSA P521 authentication
      kpt  08/27/20 Changed argument type from u8* to UINTPTR for SHA
      kpt  09/07/20 Fixed key rolling issue
      kpt  09/08/20 Added redundancy at security critical checks
      rpo  09/10/20 Added return type for XSecure_Sha3Start
      bsv  09/30/20 Renamed XLOADER_CHUNK_MEMORY to XPLMI_PMCRAM_CHUNK_MEMORY
      har  09/30/20 Deprecated Family Key support
      bm   09/30/20 Added SecureClear API to clear security critical data
                    in case of exceptions and also place AES, ECDSA_RSA,
                    SHA3 in reset
      kal  10/07/20 Added Missed DB check in XLoader_RsaSignVerify API
      kal  10/16/20 Added a check for RSA EM MSB bit to make sure it is zero
      kpt  10/19/20 Code clean up
      td   10/19/20 MISRA C Fixes
      bsv  10/19/20 Parallel DMA related changes
      har  10/19/20 Replaced ECDSA in function calls
1.04  har  11/12/20 Initialized GVF in PufData structure with MSB of shutter
                    value
                    Improved checks for sync in PDI DPACM Cfg and Efuse DPACM Cfg
      bm   12/16/20 Added PLM_SECURE_EXCLUDE macro. Also moved authentication and
                    encryption related code to <a class="el" href="xloader__auth__enc_8c.html" title="This file contains authentication and encryption related code. ">xloader_auth_enc.c</a> file
      bm   01/04/21 Updated checksum verification to be done at destination memory
      kpt  02/18/21 Fixed logical error in partition next chunk copy in encryption cases
1.05  har  03/17/21 Added API to set the secure state of device
      ma   03/24/21 Minor updates to prints in XilLoader
      bm   05/10/21 Updated chunking logic for hashes
      bm   05/13/21 Updated code to use common crypto instances from xilsecure
      ma   05/18/21 Minor code cleanup
      ma   05/20/21 Fix warnings introduced due to volatile qualifier
      har  05/20/21 Added checks in case both efuse auth and bh auth are enabled
1.06  td   07/08/21 Fix doxygen warnings
      har  07/15/21 Fixed doxygen warnings
      har  07/27/21 Added prints for Secure State
      kpt  08/11/21 Added redundant check for Xil_MemCmp in
                    XLoader_VerifyHashNUpdateNext
      bsv  08/17/21 Code clean up
      bsv  08/31/21 Code clean up
      kpt  09/09/21 Fixed SW-BP-BLIND-WRITE in XLoader_SecureClear
      kpt  09/09/21 Fixed SW-BP-BLIND-WRITE in XLoader_AuthEncClear
      kpt  09/15/21 Fixed SW-BP-INIT-FAIL in XLoader_GetAHWRoT
      kpt  09/15/21 Fixed SW-BP-INIT-FAIL in XLoader_GetSHWRoT
      kpt  09/18/21 Fixed SW-BP-REDUNDANCY
      kpt  09/20/21 Fixed checksum issue in case of delay load
      bsv  10/01/21 Addressed code review comments
1.07  kpt  10/07/21 Decoupled checksum functionality from secure code
      kpt  10/20/21 Modified temporal checks to use temporal variables from
                    data section
      bsv  10/26/21 Code clean up
      kpt  10/28/21 Added flags in XLoader_SecureInit to indicate the mode of
                    copy
1.08  skd  11/18/21 Added time stamps in XLoader_ProcessChecksumPrtn
      kpt  12/13/21 Replaced standard library utility functions with secure
                    functions
      bsv  02/09/22 Code clean up to reduce size
      bsv  02/09/22 Code clean up
      bsv  02/10/22 Code clean up by removing unwanted initializations
      bsv  02/14/22 Added comments for better readability
      kpt  02/18/22 Fixed copy to memory issue
1.09  bm   07/06/22 Refactor versal and versal_net code
      sk   10/19/22 Fix security review comments
      har  11/17/22 Removed XLoader_CheckNonZeroPpk and moved code to set
                    Secure State(Auth) in xloader_plat_secure files
      ng   11/23/22 Updated doxygen comments
      kpt  02/21/23 Fixed bug in XLoader_SecureClear
      ng   03/30/23 Updated algorithm and return values in doxygen comments
      sk   05/18/23 Deprecate copy to memory feature
      yog  07/17/23 Added check for returning glitch error for XLoader_ChecksumInit API
      ng   07/10/23 Added support for system device-tree flow
      yog  08/17/23 Added a check to return error when secure is excluded
                    and trying to do secure boot
2.1   kpt  12/13/23 Reset PMC TRNG when exception occurs
      ng   01/28/24 u8 variables optimization
      pre  12/09/24 use PMC RAM for Metaheader instead of PPU1 RAM
      pre  03/02/25 setting data context lost for SHA when the resource is busy
      pre  04/07/25 Hash verification skip for non-secure boot in export control enabled devices</pre><pre></pre> </div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:gae1ad484f4b4344573008a1fa138ad597"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xloader__server__apis.html#gae1ad484f4b4344573008a1fa138ad597">XLOADER_SHA3_RESET_REG</a>&#160;&#160;&#160;(0xF1210004U)</td></tr>
<tr class="memdesc:gae1ad484f4b4344573008a1fa138ad597"><td class="mdescLeft">&#160;</td><td class="mdescRight">SHA3 Reset register address.  <a href="group__xloader__server__apis.html#gae1ad484f4b4344573008a1fa138ad597">More...</a><br/></td></tr>
<tr class="separator:gae1ad484f4b4344573008a1fa138ad597"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga18a802ef19167e4a011890ac7bf61f7d"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xloader__server__apis.html#ga18a802ef19167e4a011890ac7bf61f7d">XLOADER_SHA3_RESET_VAL</a>&#160;&#160;&#160;(0x1U)</td></tr>
<tr class="memdesc:ga18a802ef19167e4a011890ac7bf61f7d"><td class="mdescLeft">&#160;</td><td class="mdescRight">SHA3 Reset value.  <a href="group__xloader__server__apis.html#ga18a802ef19167e4a011890ac7bf61f7d">More...</a><br/></td></tr>
<tr class="separator:ga18a802ef19167e4a011890ac7bf61f7d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga9410756c2dbe4b6bd6cdfce81a5bd7fa"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xloader__server__apis.html#ga9410756c2dbe4b6bd6cdfce81a5bd7fa">XLoader_SecureInit</a> (XLoader_SecureParams *SecurePtr, XilPdi *PdiPtr, u32 PrtnNum)</td></tr>
<tr class="memdesc:ga9410756c2dbe4b6bd6cdfce81a5bd7fa"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function initializes XLoader_SecureParams's instance.  <a href="group__xloader__server__apis.html#ga9410756c2dbe4b6bd6cdfce81a5bd7fa">More...</a><br/></td></tr>
<tr class="separator:ga9410756c2dbe4b6bd6cdfce81a5bd7fa"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga04bdca8398a9278a9c382ef66ad42ed9"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xloader__server__apis.html#ga04bdca8398a9278a9c382ef66ad42ed9">XLoader_SecureCopy</a> (XLoader_SecureParams *SecurePtr, u64 DestAddr, u32 Size)</td></tr>
<tr class="memdesc:ga04bdca8398a9278a9c382ef66ad42ed9"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function loads secure non-cdo partitions.  <a href="group__xloader__server__apis.html#ga04bdca8398a9278a9c382ef66ad42ed9">More...</a><br/></td></tr>
<tr class="separator:ga04bdca8398a9278a9c382ef66ad42ed9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9171035e129091fbaddbc27756381f76"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xloader__server__apis.html#ga9171035e129091fbaddbc27756381f76">XLoader_SecureClear</a> (void)</td></tr>
<tr class="memdesc:ga9171035e129091fbaddbc27756381f76"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function is called to clear secure critical data in case of exceptions.  <a href="group__xloader__server__apis.html#ga9171035e129091fbaddbc27756381f76">More...</a><br/></td></tr>
<tr class="separator:ga9171035e129091fbaddbc27756381f76"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga88fdae4e3fe98e871dd93c7cb31ce387"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xloader__server__apis.html#ga88fdae4e3fe98e871dd93c7cb31ce387">XLoader_VerifyHashNUpdateNext</a> (XLoader_SecureParams *SecurePtr, u64 DataAddr, u32 Size, u8 Last)</td></tr>
<tr class="memdesc:ga88fdae4e3fe98e871dd93c7cb31ce387"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function calculates hash and compares with expected hash.  <a href="group__xloader__server__apis.html#ga88fdae4e3fe98e871dd93c7cb31ce387">More...</a><br/></td></tr>
<tr class="separator:ga88fdae4e3fe98e871dd93c7cb31ce387"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga5054d79a7dcc052ae83d997f183c8779"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xloader__server__apis.html#ga5054d79a7dcc052ae83d997f183c8779">XLoader_SecureChunkCopy</a> (XLoader_SecureParams *SecurePtr, u64 SrcAddr, u8 Last, u32 BlockSize, u32 TotalSize)</td></tr>
<tr class="memdesc:ga5054d79a7dcc052ae83d997f183c8779"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function copies the data from SrcAddr to chunk memory during processing of secure partitions.  <a href="group__xloader__server__apis.html#ga5054d79a7dcc052ae83d997f183c8779">More...</a><br/></td></tr>
<tr class="separator:ga5054d79a7dcc052ae83d997f183c8779"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4e5d053bbf2e5283aac4b2a1e860b44d"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xloader__server__apis.html#ga4e5d053bbf2e5283aac4b2a1e860b44d">XLoader_CheckNonZeroPpk</a> (void)</td></tr>
<tr class="memdesc:ga4e5d053bbf2e5283aac4b2a1e860b44d"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function checks if PPK is programmed.  <a href="group__xloader__server__apis.html#ga4e5d053bbf2e5283aac4b2a1e860b44d">More...</a><br/></td></tr>
<tr class="separator:ga4e5d053bbf2e5283aac4b2a1e860b44d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3e99458db1239a8f1bcb70eee9025232"><td class="memItemLeft" align="right" valign="top">u32&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xloader__server__apis.html#ga3e99458db1239a8f1bcb70eee9025232">XLoader_GetAHWRoT</a> (const u32 *AHWRoTPtr)</td></tr>
<tr class="memdesc:ga3e99458db1239a8f1bcb70eee9025232"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function returns the state of authenticated boot.  <a href="group__xloader__server__apis.html#ga3e99458db1239a8f1bcb70eee9025232">More...</a><br/></td></tr>
<tr class="separator:ga3e99458db1239a8f1bcb70eee9025232"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga27d4a7f2cecd7b051a5418ad7586cac3"><td class="memItemLeft" align="right" valign="top">u32&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xloader__server__apis.html#ga27d4a7f2cecd7b051a5418ad7586cac3">XLoader_GetSHWRoT</a> (const u32 *SHWRoTPtr)</td></tr>
<tr class="memdesc:ga27d4a7f2cecd7b051a5418ad7586cac3"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function returns the state of encrypted boot.  <a href="group__xloader__server__apis.html#ga27d4a7f2cecd7b051a5418ad7586cac3">More...</a><br/></td></tr>
<tr class="separator:ga27d4a7f2cecd7b051a5418ad7586cac3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gade5fc1ce6a279c921672d5692df5cf56"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xloader__server__apis.html#gade5fc1ce6a279c921672d5692df5cf56">XLoader_SetSecureState</a> (void)</td></tr>
<tr class="memdesc:gade5fc1ce6a279c921672d5692df5cf56"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function reads the value of PPK efuse bits, DEC only efuse bits and fields in bootheader and accordingly sets the Secure State of boot.  <a href="group__xloader__server__apis.html#gade5fc1ce6a279c921672d5692df5cf56">More...</a><br/></td></tr>
<tr class="separator:gade5fc1ce6a279c921672d5692df5cf56"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga31df7acaead3af0dfa1735979d3cee12"><td class="memItemLeft" align="right" valign="top">XLoader_SecureTempParams *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__xloader__server__apis.html#ga31df7acaead3af0dfa1735979d3cee12">XLoader_GetTempParams</a> (void)</td></tr>
<tr class="memdesc:ga31df7acaead3af0dfa1735979d3cee12"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function returns the pointer to XLoader_SecureTempParams.  <a href="group__xloader__server__apis.html#ga31df7acaead3af0dfa1735979d3cee12">More...</a><br/></td></tr>
<tr class="separator:ga31df7acaead3af0dfa1735979d3cee12"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
	<p class="footer">&copy; Copyright 2015-2022 Xilinx, Inc. All Rights Reserved.</p>
	<p class="footer">&copy; Copyright 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.</p>
</div>
</body>
</html>
